package com.all.play.myapplication.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.MotionEvent;

import com.all.play.myapplication.MainActivity;
import com.all.play.myapplication.R;
import com.all.play.myapplication.utils.CheckPermissionsActivity;

/**
 * Created by 聪明一只哈 on 2018/3/28.
 */

public class SplashActivity extends CheckPermissionsActivity {
    public static final String TAG=SplashActivity.class.getSimpleName();

    private Handler handler=new Handler();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        handler.postDelayed(new Runnable() {
            @Override
            public void run() {

              //跳到主页面
                startMainActivity();
                Log.e(TAG, "run: "+"startMainActivity" );

            }
        },2000);

    }

    private void startMainActivity() {
        startActivity(new Intent(SplashActivity.this, MainActivity.class));
        finish();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.e(TAG, "run: "+"onTouchEvent" );
        startMainActivity();
        return super.onTouchEvent(event);
    }

    @Override
    protected void onDestroy() {
        handler.removeCallbacksAndMessages(null);
        super.onDestroy();
    }
}
